package com.hxkj.dao.impl;

import com.alicp.jetcache.anno.CacheUpdate;
import com.hxkj.dao.ColumnDao;
import com.hxkj.domain.po.Column;
import com.hxkj.mapper.ColumnMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
* 数据操作实现
*
* @author: chenwei
* @version: 1.0
* @datetime: 2018-06-05 19:32:55
*
*/
@Service("columnDao")
public class ColumnDaoImpl implements ColumnDao {

    @Resource
    private ColumnMapper columnMapper;


    @Override
    public int saveColumn(Column column) {
        column.setCreateTime(System.currentTimeMillis());
        column.setUpdateTime(System.currentTimeMillis());
        return columnMapper.saveColumn(column);
    }

    @Override
    public List<Column> getColumnList(Column column) {
        return columnMapper.getColumnList(column);
    }

    @Override
    public List<Column> getColumnByName(String columnName,Long siteId) {
        Column column = new Column();
        column.setColumnName(columnName);
        column.setSiteId(siteId);
        return columnMapper.getColumnByName(column);
    }


    @Override
    public int removeColumnById(Long columnId) {
        return columnMapper.removeColumnById(columnId);
    }

    @Override
    public List<Column> getColumnByParentColumnId(Long parentColumnId) {
        return columnMapper.getColumnByParentColumnId(parentColumnId);
    }

    @Override
    public Column getColumnById(Long columnId) {
        return columnMapper.getColumnById(columnId);
    }

    @Override
    @CacheUpdate(name = "column:columnId:",key = "#column.columnId",value = "#column")
    public int modifyColumn(Column column) {
        column.setUpdateTime(System.currentTimeMillis());
        return columnMapper.modifyColumn(column);
    }

    @Override
    public int modifySortNum(Column column) {
        column.setUpdateTime(System.currentTimeMillis());
        return columnMapper.modifySortNum(column);
    }

    @Override
    public List<Column> getShowColumnList(Column column) {
        return columnMapper.getShowColumnList(column);
    }

    @Override
    public List<Column> getOptionColumnList(Column column) {
        return columnMapper.getOptionColumnList(column);
    }

    @Override
    public Column getColumnByName_(Column column) {
        return columnMapper.getColumnByName_(column);
    }

    @Override
    public List<Column> getColumnListByTempletIds(Column column) {
        return columnMapper.getColumnListByTempletIds(column);
    }

    @Override
    public List<Column> getColumnByTempletId(Column column) {
        return columnMapper.getColumnByTempletId(column);
    }

    @Override
    public int modifyTemptId(Column column) {
        return columnMapper.modifyTemptId(column);
    }

    @Override
    public int removeContentByColumnId(Long columnId) {
        return columnMapper.removeContentByColumnId(columnId);
    }

    @Override
    public List<Column> getColumnByAlias(String alias, Long siteId) {
        Column column = new Column();
        column.setAlias(alias);
        column.setSiteId(siteId);
        return columnMapper.getColumnByAlias(column);
    }
}
